<?php

class AdminPermissionsController extends Base {
  use CURD;

  public $tableName = 'admin_permissions';
  protected $likeField = ['name','parent_id','slug']; 
  protected $deleted_at = false;
  protected $isTree = false;



  public function formatListExtra($list){

		return $list;
  }


  



  public function treeAction(){
  	$list = $this->db->select($this->tableName,['name','parent_id','slug','id']);
  	$result = [];
  	foreach ($list as $value) {
  		if(!isset($result[$value['parent_id']])){
  			$result[$value['parent_id']] = [];  			
  		}
  		$result[$value['parent_id']][] = [
			'title'=>$value['name'],
			'key'=>$value['parent_id'].($value['slug']?'.'.$value['slug']:'').':'.$value['id']
		];
  	}
  	success($result);
  }

}
